package com.yusys;

public class 多态练习题02 {
    public static void main(String[] args) {
        Sub s = new Sub();
        System.out.println(s.count); // 20
        s.display(); // 20
        Base b = s;
        // 指向同一个对象
        System.out.println(b == s); // true
        System.out.println(b.count); // 10
        // 运行类型是Sub
        b.display(); // 20
    }
}

class Base {
    int count = 10;

    public void display() {
        System.out.println(this.count);
    }
}

class Sub extends Base {
    int count = 20;

    public void display() {
        System.out.println(this.count);
    }
}
